package stu.sup.service.impl;

import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import stu.sup.entity.Product;
import stu.sup.mapper.ProductMapper;
import stu.sup.service.IProductService;

import java.util.List;

/**
 * Created by HUAWEI on 2020/6/22.
 */
@Service
public class ProductServiceImpl implements IProductService{

    @Autowired
    private ProductMapper productMapper;

    @Override
    public int insert(Product product) {
        int row = productMapper.insert(product);
        return row;
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return productMapper.deleteByPrimaryKey(id);
    }

//    @Override
//    public int updateByPrimaryKey(Product product) {
//        return productMapper.updateByPrimaryKey(product);
//    }

    @Override
    public int updateByPrimaryKeySelective(Product product) {
        return productMapper.updateByPrimaryKeySelective(product);
    }

    @Override
    public List<Product> selectByConditional(Product product, int pageNum,int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Product> productList = productMapper.findByConditional(product);
        return productList;
    }

    @Override
    public Product selectbyId(int productId) {
        return productMapper.selectByPrimaryKey(productId);
    }


}
